import React, { useRef } from 'react';
import _ from 'lodash';
import moment from 'moment';

import { useTRState } from '@/pages/ETrade/components';
import TjForm from '@/components/TjForm';

export default ({ power = [], onFinish, onChangeForm, tableData = [], onExport }) => {
  const formRef = useRef(null);

  const [state, setState] = useTRState({
    initialValues: {
      useTo: '',
      keyword: '',
      date: [moment().startOf('day'), moment().endOf('day')],
    },
  });

  const formList = [
    // {
    //   type: 'Input',
    //   name: 'useTo',
    //   props: {
    //     placeholder: '请输入用途',
    //   },
    // },
    {
      type: 'Input',
      name: 'keyword',
      props: {
        placeholder: '请输入关键字',
      },
    },
    {
      type: 'RangePicker',
      name: 'date',
      props: {
        allowClear: false,
      },
    },
  ];

  const onValueChange = (value) => {
    onChangeForm(value);
  };

  return (
    <TjForm
      ref={formRef}
      onFinish={onFinish}
      onValuesChange={onValueChange}
      list={formList}
      initialValues={state.initialValues}
      // right={
      //   <Button
      //     disabled={!tableData?.length}
      //     style={{ padding: 0 }}
      //     type="link"
      //     icon={<UploadOutlined />}
      //     onClick={onExport}
      //   >
      //     导出
      //   </Button>
      // }
    />
  );
};
